<?php
namespace Acme\FirmsBundle\lib;

use Alex616\jqGridBundle\lib\ConfigurationClass;

class AdminCategoryConfigJqGrid extends ConfigurationClass {
  
  protected function initJqGrid() {
    $jqGrid = $this->getJqGrid();
    $jqGrid->setProperty('url', null)
           ->setProperty('datatype', 'json')
           ->startBlock('colNames')
            ->setProperty(null, 'Id')
            ->setProperty(null, 'Название Категории')
           ->endBlock()
           ->startBlock('colModel')
            ->startBlock()
              ->setProperty('name', 'id')
              ->setProperty('index', 'id')
              ->setProperty('width', 25)
              ->setProperty('editable', false)
              ->startBlock('editoptions')
                ->setProperty('readonly', true)
                ->setProperty('size', 10)
              ->endBlock()
            ->endBlock()
            ->startBlock()
              ->setProperty('name', 'name')
              ->setProperty('index', 'name')
              ->setProperty('width', 55)
              ->setProperty('editable', true)
              ->startBlock('editoptions')
                ->setProperty('size', 25)
              ->endBlock()
            ->endBlock()
           ->endBlock()
           ->setProperty('rowNum', 10)
           ->startBlock('rowList')
            ->setProperty(null, 10)
            ->setProperty(null, 20)
            ->setProperty(null, 30)
           ->endBlock()
            ->setProperty('pager', '#pager2')
            ->setProperty('sortname', 'id')
            ->setProperty('viewrecords', true)
            ->setProperty('sortorder', 'asc')
            ->setProperty('multiselect', true)
            ->setProperty('caption', 'Фирмы')
            ->setProperty('editurl', null)
            ->setProperty('width', 800)
           ;
  }
  
  public function processData($value) {
    return array('id'   => $value->getId(),
                 'cell' => array($value->getId(),
                                 $value->getName())
                );
  }
}
